<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dashboard测试 - 带Token</title>
    <style>
        body {
            margin: 0;
            padding: 20px;
            font-family: Arial, sans-serif;
            background: #f5f5f5;
        }
        .test-panel {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            margin-bottom: 20px;
            text-align: center;
        }
        .button {
            background: #1890ff;
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 4px;
            cursor: pointer;
            margin: 10px;
            font-size: 16px;
        }
        .button:hover {
            background: #40a9ff;
        }
        .status {
            padding: 15px;
            border-radius: 4px;
            margin: 15px 0;
            font-size: 16px;
        }
        .success {
            background: #f6ffed;
            border: 1px solid #b7eb8f;
            color: #52c41a;
        }
    </style>
</head>
<body>
    <div class="test-panel">
        <h2>🔐 Dashboard访问测试</h2>
        <p>这个页面会自动设置测试token并跳转到dashboard</p>
        
        <div id="status" class="status success">
            ⏳ 正在设置测试token...
        </div>
        
        <button class="button" onclick="goToDashboard()">立即跳转到Dashboard</button>
        <button class="button" onclick="goToSimpleDashboard()">跳转到简化Dashboard</button>
        <button class="button" onclick="clearAndGoToLogin()">清除Token并跳转登录</button>
    </div>
    
    <script>
        console.log('🚀 Dashboard测试页面加载');
        
        // 自动设置测试token
        function setTestToken() {
            const testToken = 'test-admin-token-' + Date.now();
            localStorage.setItem('admin_token', testToken);
            console.log('✅ 测试token已设置:', testToken);
            
            document.getElementById('status').innerHTML = `
                ✅ 测试Token已设置成功！<br/>
                <small>Token: ${testToken}</small>
            `;
        }
        
        function goToDashboard() {
            console.log('🎯 跳转到完整Dashboard页面');
            window.location.href = '/dashboard';
        }
        
        function goToSimpleDashboard() {
            console.log('🎯 跳转到简化Dashboard页面');
            window.location.href = '/simple-dashboard';
        }
        
        function clearAndGoToLogin() {
            localStorage.removeItem('admin_token');
            console.log('🗑️ Token已清除，跳转到登录页面');
            window.location.href = '/login';
        }
        
        // 页面加载时自动设置token
        window.addEventListener('load', () => {
            setTimeout(setTestToken, 500);
        });
        
        // 3秒后自动跳转到dashboard
        setTimeout(() => {
            console.log('⏰ 自动跳转到Dashboard页面');
            goToDashboard();
        }, 3000);
    </script>
</body>
</html>